<?
if (isset($_POST['btnsubmit'])) {
    require("required/dbconnect.php");

    $country_id=$_POST['country_id'];
    $status=$_POST['status'];
    
    mysql_query("update os_country set status='$status' where id='$country_id'") or die(mysql_error());
    header("Location:country_view_full.php?action=3&id=$country_id");
}

require("required/dbconnect.php");
require("required/header.php");
require("required/function.php");
checkAccess("allow_shipping_management", 1);
?>
<script src="required/js/jquery-1.4.2.js"></script>
<script src="required/js/common_javascript.js"></script>
<?
checkAccess("allow_product_management", 1);
if (!empty($_GET['action'])) {
    switch ($_GET['action']) {
        case 1:
            $msg = "<div class='dw_success'>Data inserted</div>";
            break;
        case 2:
            $msg = "<div class='dw_success'>Data Deleted</div>";
            break;
        case 3:
            $msg = "<div class='dw_success'>Data Updated</div>";
            break;
        default:
            $msg = "";
            break;
    }
    echo "<script>displayMsg('divMsg')</script>";
} else {
    $msg = "";
}

$country_id = $_GET['id'];
$get_country = mysql_query("select * from os_country where id=$country_id") or die(mysql_error());

$a = mysql_fetch_array($get_country, MYSQL_ASSOC);

if ($a['area_type'] == "") {
    $area_type = "State";
} else {
    $area_type = $a['area_type'];
}

$slt0 = $slt1 = "";

if ($a['status'] == 1) {
    $slt1 = "selected";
} else {
    $slt0 = "selected";
}


$get_state = mysql_query("select * from os_state where country_id='$country_id' order by name_eng asc") or die(mysql_error());
?>

<table width="100%">
    <td width="100%" align="left" valign="top">
        <div class="title">Country : <?= $a['engname'] ?> 
        </div>
        <form method="post" action="<?= $_SERVER['PHP_SELF'] ?>"> 
            <table>
                <tr>
                    <td>
                        Publish : 
                        <select name="status">
                            <option value="1" <?= $slt1 ?>>Yes</option>
                            <option value="0" <?= $slt0 ?>>No</option>                        
                        </select>
                        <input type="hidden" value="<?= $country_id ?>" name="country_id"> 
                        <input type="submit" value="Update" name="btnsubmit">
                    </td>
                </tr>
            </table>
        </form>
        <div id="divMsg"><?= $msg ?></div>
        <table width="80%" cellpadding="3" class="solidborder">
            <tr class="table_header" align="center" height="20">
                <td width="3%">No</td><td width="23%"><?= $area_type ?> Name</td>
            </tr>
            <?
            if (mysql_num_rows($get_state) == 0) {
                ?>
                <tr>
                    <td align=center colspan="6"> - No record -</td>
                </tr>
                <?
            } else {
                $no = 1;
                while ($a = mysql_fetch_array($get_state, MYSQL_ASSOC)) {
                    $id = $a['id'];

                    if ($no % 2 == 0) {
                        $class1 = "table_item_even";
                        $class2 = "table_item_odd";
                    } else {
                        $class1 = "table_item_odd";
                        $class2 = "table_item_even";
                    }
                    ?>
                    <tr height="20" valign="top" class="<?= $class1 ?>"  onmouseover="this.className='table_item_mouseover'" 
                        onmouseout="this.className='<?= $class1 ?>'">
                        <td align="center"><?= $no ?></td>
                        <td><?= $a['name_eng'] ?></td>

                    </tr>
                    <?
                    $no++;
                }
            }
            ?>
        </table><input type="button" value="Back" class="button" onclick="window.open('country_view_all.php','_self')">


    </td>



</table>
<? require("required/footer.php"); ?>